﻿@using GoodMan.Infrastructure.Entities.Entity;
@using GoodMan.Infrastructure.Entities.Enum;
@using GoodMan.Portal.Biz;
@{
    Layout = "~/Views/Shared/_Main.cshtml";
    User user = ViewBag.User;
    Integration integration = ViewBag.Integration;
}
<br />
<div class="row-fluid">
    <div class="span3">
        <div class="border-gray bg-gray">
            <ul class="nav nav-list">
                <li class="nav-header">用户管理</li>
                <!--active-->
                <li class="active"><a href="/usercenter/index">管理首页</a></li>
                <li class=""><a href="/usercenter/order">我的订单</a></li>
                <li class=""><a href="/usercenter/info">个人资料</a></li>
                <li class=""><a href="/usercenter/mypwd">修改密码</a></li>
            </ul>
        </div>
    </div>
    <div class="span9">
        <div class="border-gray bg-gray">
            <div class="padding-5">
                <div class="row-fluid ">
                    <div class="span2">
                        <!--100x100-->
                        <img alt="user" style="width: 100px; height: 100px;" src="/content/img/avatar.png" />
                    </div>
                    <div class="span10">
                        <div>
                            <strong>@user.RealName (@user.NickName)
                                @{
                                    int hour = DateTime.Now.Hour;
                                    if (hour >= 0 && hour < 4)
                                    {
                                    <span>， 夜深了</span>
                                    }
                                    else if (hour >= 4 && hour < 12)
                                    {
                                    <span>， 上午好</span>
                                    }
                                    else if (hour >= 12 && hour < 14)
                                    {
                                    <span>， 中午好</span>
                                    }
                                    else if (hour >= 14 && hour < 18)
                                    {
                                    <span>， 下午好</span>
                                    }
                                    else if (hour >= 18 && hour <= 24)
                                    {
                                    <span>， 晚上好</span>
                                    }
                                }
                            </strong>
                        </div>
                        <div>
                            @if (integration != null)
                            {
                                <small>剩余积分：@integration.CostValue</small>
                            }
                            else
                            { 
                                <small>剩余积分：0</small>
                            }
                        </div>
                        <div>
                            <small>帐户余额：
                                @if (integration == null || integration.Balance == 0)
                                { 
                                    <strong class="red text-large">0.00</strong>
                                    if (integration != null && integration.LockBalance > 0)
                                    { 
                                    <span style="color: Green;">&nbsp;&nbsp;(等待退款：@integration.LockBalance)</span>
                                    }
                                }
                                else
                                { 
                                    <strong class="red text-large">@integration.Balance</strong>
                                    <a href="/usercenter/refund">[申请退款]</a>
                                    if (integration != null && integration.LockBalance > 0)
                                    { 
                                    <span style="color: Green;">&nbsp;&nbsp;(等待退款：@integration.LockBalance)</span>
                                    }
                                }
                            </small>
                        </div>
                        <div>
                            <small>账号安全：<span class="badge badge-success">邮箱已认证</span>&nbsp;&nbsp;
                                @if (!String.IsNullOrEmpty(user.QQ) && !String.IsNullOrEmpty(user.IdCardNo))
                                { 
                                    <span class="badge badge-success">资料已完善</span>
                                }
                                else
                                { 
                                    <a href="/usercenter/info" class="badge badge-important">有更多资料需要完善</a>
                                }
                            </small>
                        </div>
                        <div>
                            <small>累计消费：<span class="">@ViewBag.AllOrderPrice 元</span></small>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <br />
        <div class="border-gray">
            <div class="title-preview">
                <div class="pull-right">
                    <a href="/usercenter/order">更多</a></div>
                <div class="pull-left">
                    <a><strong>最新交易</strong></a></div>
            </div>
            <div class="padding-10">
                <table class="table table-x">
                    <thead>
                            <tr>
                                <th>
                                    商品名称
                                </th>
                                <th style="width: 15%">
                                    消费
                                </th>
                                <th style="width: 22%">
                                    交易时间
                                </th>
                                <th style="width: 15%">
                                    状态
                                </th>
                                <th style="width: 15%">
                                </th>
                            </tr>
                    </thead>
                    <tbody>
                        @{
                            List<Order> orders = ViewBag.Order;
                            if (orders != null && orders.Any())
                            {
                                foreach (var item in orders)
                                {
                                    
                        <tr>
                            <td>
                                <div style="width:250px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;display:block;"><a href="/usercenter/orderdetail/@item.Id" target="_blank">@Html.Raw(item.ProductDescript)</a></div>
                            </td>
                            <td>
                                <strong>
                                @if(item.AreaCode == AreaCode.Integration)
                                {
                                @((int)(item.TotalPrice * GoodMan.Tool.Configration.SiteResource.CostRank)) @:(积分)
                                }
                                else
                                {
                                @item.TotalPrice
                                }
                                </strong>
                            </td>
                            <td>
                                @item.OrderDate.ToString("yyyy-MM-dd HH:ss")
                            </td>
                            <td>
                                @if (item.Status == OrderStatus.Completed)
                                {
                                    <span class="label label-success">@item.Status.Mapping()</span>
                                }
                                else if (item.Status == OrderStatus.WaitForDeliver || item.Status == OrderStatus.Paid)
                                {
                                    <span class="label label-warning">@item.Status.Mapping()</span>
                                }
                                else if (item.Status == OrderStatus.Reserved)
                                {
                                    <span class="label label-info">@item.Status.Mapping()</span>
                                }
                                else
                                {
                                    <span class="label">@item.Status.Mapping()</span>
                                }
                            </td>
                            <td>
                            @if (item.Status == OrderStatus.Reserved)
                            {
                                <a class="btn btn-success btn-mini" href="/shop/UserCenterPay/@item.Id" >立即付款</a>
                            }
                             @if (item.Status == OrderStatus.Completed)
                             {
                                 if (OrderBiz.IsViewAppraisie(item.Id))
                                 {
                                <a href="/usercenter/ProductAppraisie/@item.Id" class="btn btn-primary btn-mini">评价</a>
                                 }
                                 else
                                 {
                                    <span>已评</span>
                                 }
                             }
                            </td>
                        </tr>
                                }
                            }
                        }
                    </tbody>
                    <tfoot>
                        <tr>
                            <th colspan="5">
                                <div class="text-right">
                                    <a href="/usercenter/order" class="btn btn-danger">
                                        <span class="icon-white icon-search"></span>&nbsp;查看更多
                                    </a>
                                </div>
                            </th>
                        </tr>
                    </tfoot>
                </table>
            </div>
        </div>
        <!--#购物车preview-->
        <br />
    </div>
</div>
<br />
<br />
